There are at least five grouping methods for sample adaptive offset (SAO) compensation in high efficiency video coding (HEVC) standard. The five grouping method are band offset (BO), edge offset 1 (EO1), edge offset 2 (EO2), edge offset 3 (EO3), and edge offset 4 (EO4). Referring to FIG. 1, FIG. 1 is a diagram of band offset grouping method. The unit for SAO compensation is a block. The block size specified in the standard may be 64×64, 32×32, 16×16, etc. There are two steps specified in SAO compensation process. At first, the pixels of the reconstructed picture in the block are divided into groups. The reconstructed pixels with pixel values 0˜7 are grouped as group 1, the reconstructed pixels with pixel values 8˜15 as group 2, etc. The reconstructed pixels can be divided into 32 groups. Then, SAO compensation for the reconstructed pixels in each group is performed respectively. The group 1 to group 32 are corresponding to SAO compensation value a1 to a32 respectively.
Referring to both FIG. 2 and FIG. 3, FIG. 2 is a diagram of an original picture. FIG. 3 is a diagram of generating a compensated picture according to a reconstructed picture and SAO compensation values. To be simplified for description, a 3×3 block is used as an example in FIG. 2. The compensated picture is obtained by adding the reconstructed pixels of the reconstructed picture with SAO compensation values respectively. The SAO compensation value corresponding to group 1 is +2, and the SAO compensation value corresponding to group 2 is −1. The compensated pixels shown in FIG. 3 are consistent with the original pixels shown in FIG. 2 basically.
Referring to FIG. 4, FIG. 5, FIG. 6, and FIG. 7. FIG. 4 is a diagram of edge offset 1 grouping method. FIG. 5 is a diagram of edge offset 2 grouping method. FIG. 6 is a diagram of edge offset 3 grouping method. FIG. 7 is a diagram of edge offset 4 grouping method. The directional patterns for edge offset 1, edge offset 2, edge offset 3, and edge offset 4 are horizontal, vertical, 135 degree diagonal, and 45 degree diagonal respectively. The group 1 to group 4 are corresponding to SAO compensation value a1 to a4 respectively. For example, as shown in FIG. 4, when the pixel value of a reconstructed pixel a and the pixel value of a reconstructed pixel b are larger than the pixel value of a reconstructed pixel c, the reconstructed pixel c is classified as group 1. The reconstructed pixels in group 1 are corresponding to SAO compensation value a1. When the pixel value of the reconstructed pixel a and the pixel value of the reconstructed pixel c are the same, and the pixel value of the reconstructed pixel a and the pixel value of the reconstructed pixel c are smaller than the pixel value of the reconstructed pixel b, the reconstructed pixel c is classified as group 2. Or, when the pixel value of the reconstructed pixel b and the pixel value of the reconstructed pixel c are the same, and the pixel value of the reconstructed pixel b and the pixel value of the reconstructed pixel c are smaller than the pixel value of the reconstructed pixel a, the reconstructed pixel c is classified as group 2. The reconstructed pixels in group 2 are corresponding to SAO compensation value a2.
When the pixel value of the reconstructed pixel a and the pixel value of the reconstructed pixel c are the same, and the pixel value of the reconstructed pixel a and the pixel value of the reconstructed pixel c are larger than the pixel value of the reconstructed pixel b, the reconstructed pixel c is classified as group 3. Or, when the pixel value of the reconstructed pixel b and the pixel value of the reconstructed pixel c are the same and the pixel value of the reconstructed pixel b and the pixel value of the reconstructed pixel c are larger than the pixel value of the reconstructed pixel a, the reconstructed pixel c is classified as group 3. The reconstructed pixels in group 3 are corresponding to SAO compensation value a3. When the pixel value of the reconstructed pixel a and the pixel value of the reconstructed pixel b are smaller than the pixel value of the reconstructed pixel c, the reconstructed pixel c is classified as group 4. The reconstructed pixels in group 4 are corresponding to SAO compensation value a4. The reconstructed pixels in group 1, in group 2, in group 3, and in group 4 are SAO compensated according to the corresponding SAO compensation value a1, SAO compensation value a2, SAO compensation value a3, SAO compensation value a4 respectively.